home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / music / edplayer_2.1 / telled.asm < prev    next >
Assembly Source File  |  1994-11-17  |  5KB  |  133 lines

  1. ;
  2. ;     TellEd 2.0          by Ed Mackey
  3. ;        (Communicate        PO Box 475
  4. ;         with EdPlayer)     Wayne, PA 19087
  5.  
  6. ;  Here is the source code, assembled with Assempro by Abacus, the same
  7. ;  assembler used to create Ball, MegaBall, and EdPlayer itself.
  8.  
  9. ;  This program should be distributed with EdPlayer.  See EdPlayer.DOC
  10. ;  for usage info.
  11.  
  12. ;  After assembling, type "PROTECT TellEd +P" at a CLI so that the PURE
  13. ;  flag is set.  This program is PURE so that you can make it resident
  14. ;  with "resident" or "Ares" if you have it.
  15.  
  16. ;  V2.0 note: This version added some error checking that should have
  17. ;             been here all along, like what happens if there are no
  18. ;             args.  I THOUGHT I had that in 1.0, but I never tested
  19. ;             it, and it didn't work.
  20.  
  21.        Include 'includes:IncludeMe'
  22.        Include 'includes:exec/types.i'
  23.        Include 'includes:exec/lists.i'
  24.        Include 'includes:exec/memory.i'
  25.  
  26.        ILABEL  'includes:Amiga.L'
  27.  
  28.        move.l  #21,d7    ;Error retcode in case of early exit
  29.        move.l  d0,d5          ;Length of CLI arguments in d5
  30.        cmp.l   #3,d5
  31.        ble     MemKicked      ;If no arguments, just exit.
  32.        cmp.l   #300,d5
  33.        bge     MemKicked
  34.        cmp.l   #0,a0
  35.        beq     MemKicked
  36.        move.l  EBase,a6
  37.        move.l  #384,d0
  38.        move.l  #MEMF_CLEAR+MEMF_PUBLIC,d1
  39.        move.l  a0,a3       ;Save the args in a3
  40.        jsr     _LVOAllocMem(a6)  ;Dynamic allocation for PURE program!
  41.        move.l  d0,a4   ;0(a4) = MsgPort, 40(a4) = Message,
  42.        tst.l   d0      ;84(a4) = CopyArgs buffer
  43.        beq     MemKicked
  44.        move.b  #4,8(a4)   ;Type = MsgPort
  45.        move.b  #1,9(a4)   ;Pri = 1
  46.        move.b  #5,48(a4)  ;Type = message
  47.        move.l  a3,a0       ;Bring the CLI args back to a0
  48.        move.l  d5,d0
  49.        subq    #1,d0       ;Arg length minus 1
  50.        lea     84(a4),a2      ;I copy the args to a buffer here,
  51. MoreCp:move.b  (a0)+,(a2)+    ;but I probably don't need to.
  52.        dbra    d0,MoreCp
  53.        move.l  d5,d0
  54.        subq.l  #1,d0
  55.        lea     84(a4),a0      ;Trim off funny chars from the args
  56.        move.l  a0,a1
  57. KillJ: tst.b   (a0)
  58.        beq     RmSpc
  59.        cmp.b   #$a,(a0)+      ;Remove any 0x0A characters
  60.        beq     NoJ
  61.        dbra    d0,KillJ
  62. NoJ:   subq.l  #1,a0
  63. RmSpc: clr.b   (a0)          ;Remove trailing spaces
  64.        cmp.l   a0,a1
  65.        bhs     BOL         ;Don't delete past Beginning Of Line
  66.        cmp.b   #' ',-(a0)
  67.        beq     RmSpc
  68. BOL:   lea     20(a4),a0      ;Now:  Prepare the replyport!
  69.        NEWLIST a0
  70.        sub.l   a1,a1
  71.        move.l  EBase,a6
  72.        jsr     _LVOFindTask(a6)  ;My task # in replyport
  73.        move.l  a4,a2
  74.        move.l  d0,16(a2)
  75.        lea     40(a4),a3   ;PORT is in A2, MESSAGE is in A3
  76.        move.l  a2,14(a3)
  77.        move.w  #44,18(a3)  ;LENGTH IS .W!
  78.        lea     84(a4),a5
  79.        move.l  a5,40(a3)   ;Put arg pointer in message
  80.        move.l  #-1,d0
  81.        jsr     _LVOAllocSignal(a6)  ;Get a signal for replyport
  82.        cmp.b   #-1,d0
  83.        beq     SigKicked
  84.        move.b  d0,15(a2)
  85.        moveq.l #1,d1
  86.        and.l   #$ff,d0
  87.        lsl.l   d0,d1
  88.        move.l  d1,d6       ;Save signal in expanded (mask) form
  89.        jsr     _LVOForbid(a6)  ;Forbid before using FindPort()
  90.        lea     FindMe,a1
  91.        jsr     _LVOFindPort(a6)  ;Find EdPlayer!
  92.        tst.l   d0
  93.        beq     NoPrt
  94.        move.l  d0,a0
  95.        lea     40(a4),a1
  96.        jsr     _LVOPutMsg(a6)   ;Send message to EdPlayer!
  97.        jsr     _LVOPermit(a6)   ;Don't forget to Permit() AFTER msg sent.
  98. TryAgn:move.l  a4,a0
  99.        jsr     _LVOGetMsg(a6)   ;Look for returned message
  100.        tst.l   d0
  101.        bne     GotIt
  102.        move.l  d6,d0
  103.        jsr     _LVOWait(a6)     ;Or Wait() for returned message
  104.        bra     TryAgn           ;and try again!
  105. GotIt: move.l  d0,a5
  106.        move.l  32(a5),d7        ;Load return code.
  107. ende:
  108.        move.l  EBase,a6
  109.        moveq.l #0,d0
  110.        move.b  15(a4),d0
  111.        jsr     _LVOFreeSignal(a6)   ;Deallocate stuff.
  112. SigKicked:
  113.        move.l  EBase,a6
  114.        move.l  #384,d0
  115.        move.l  a4,a1
  116.        jsr     _LVOFreeMem(a6)
  117. MemKicked:
  118.        move.l  d7,d0
  119.        rts                          ;that's all folks!
  120.  
  121. NoPrt: jsr     _LVOPermit(a6)
  122.        move.l  #21,d7           ;Failure:  EdPlayer not found.
  123.        bra     ende
  124.  
  125.        ;data section!
  126. FindMe:
  127.        dc.b    'EDPLAYER',0   ;Find this port
  128.  
  129.        dc.b    'Telled v2.0 by Ed Mackey',0  ;Just identification
  130.        align
  131.  
  132.        END
  133.